package com.lims.utils;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

/**
 * @author limaosheng
 * @create 2022-05-10 14:18
 * @desc
 */
public class FileUtil {

    public static void write(String path,String data){
        try {
            File writeName = new File(path); // 相对路径，如果没有则要建立一个新的output.txt文件
            if(!writeName.exists()) {
                writeName.createNewFile(); // 创建新文件,有同名的文件的话直接覆盖
            }
            FileWriter writer = new FileWriter(writeName);
            BufferedWriter out = new BufferedWriter(writer);
            out.write(data);
            out.flush(); // 把缓存区内容压入文件    out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
